package demo;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    //门牌制作
    public static void main1(String[] args) {
        int count = 0;
        for (int i = 1; i <= 2020; i++) {
            int val = i;
            while(val>0) {
                if(val%10==2) {
                    count++;
                    System.out.println(val);
                }
                val /= 10;
            }
        }
        System.out.println(count);
    }

    //向字符串添加空格
    public String addSpaces(String s, int[] spaces) {
        StringBuilder sb = new StringBuilder();
        int st = 0;
        for (int i = 0; i < spaces.length; i++) {
            String str = s.substring(st, spaces[i]);
            sb.append(str).append(" ");
            st = spaces[i];
        }
        sb.append(s.substring(st));
        return sb.toString();
    }
}
